<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Hardware Abstraction Layer (HAL)</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="logo.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Hardware Abstraction Layer (HAL)</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__group__hal__nvm.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#groups">API Reference</a> &#124;
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">NVM (Onboard Non-Volatile Memory)<div class="ingroups"><a class="el" href="group__group__hal.html">HAL Drivers</a></div></div></div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">General Description</h2>
<p >High level interface to the onboard Non-Volatile memory (Internal Flash, RRAM, OTP region). </p>
<p >Onboard NVM provides non-volatile storage for factory settings, secure data, user firmware, configuration, and bulk data.</p>
<p >This driver allows data to be read from and written to NVM. It also provides the ability to obtain information about the address and characteristics of the NVM block(s) contained on the device. During NVM write time, the device should not be reset (including XRES pin, software reset, and watchdog) or unexpected changes may be made to portions of the NVM. Also, the low-voltage detect circuits should be configured to generate an interrupt instead of a reset.</p>
<dl class="section note"><dt>Note</dt><dd>A Read while Write violation may occur for some devices when a NVM Read operation is initiated in the same or neighboring NVM sector/region where the NVM Write, Erase(if applicable), or Program operation is working. Refer the device datasheet for more information. This violation may cause a HardFault exception. To avoid the Read while Write violation, the user must carefully split the Read and Write operations on NVM sectors/regions which are not neighboring, considering all cores in a multi-processor device. User may edit the linker script to place the code into neighboring sectors/regions. For example, use sectors number 0 and 1 for code and sectors 2 and 3 for data storage.</dd></dl>
<h1><a class="anchor" id="hal_nvm_features"></a>
Features</h1>
<ul>
<li>NVM operations are performed on a per-block (program) or per-sector (erase if applicable) basis (Refer the device datasheet for more information on the block size)</li>
<li>Supports Blocking or Non-Blocking erase(if applicable), program, and write </li>
</ul>
<h1><a class="anchor" id="hal_nvm_code_snippet"></a>
Code Snippets</h1>
<h2><a class="anchor" id="subsection_nvm_use_case_1"></a>
Snippet 1: Get NVM Characteristics</h2>
<p >Following code snippet demonstrates how to fetch NVM characteristics. Refer <a class="el" href="group__group__hal__nvm.html#structcyhal__nvm__info__t">cyhal_nvm_info_t</a> for more information. </p><div class="fragment"><div class="line"> </div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a>               nvm_obj;</div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__nvm.html#structcyhal__nvm__info__t">cyhal_nvm_info_t</a>          nvm_info;</div>
<div class="line">    <a class="code hl_enumeration" href="group__group__hal__nvm.html#ga9f4757bde03ab2a481207b83b39f4e1e">cyhal_nvm_type_t</a>          nvm_type = <a class="code hl_enumvalue" href="group__group__hal__nvm.html#gga9f4757bde03ab2a481207b83b39f4e1ea2842bbba59be0d2ce09b8d35c048afc5">CYHAL_NVM_TYPE_FLASH</a>;</div>
<div class="line">    uint32_t            nvm_start_address   = 0;</div>
<div class="line">    uint32_t            nvm_size            = 0;</div>
<div class="line">    uint32_t            nvm_sector_size     = 0;</div>
<div class="line">    uint32_t            nvm_block_size      = 0;</div>
<div class="line">    uint8_t             nvm_erase_value     = 0;</div>
<div class="line">    <span class="keywordtype">bool</span>                is_erase_required   = <span class="keyword">false</span>;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Initialize NVM object</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__nvm.html#gace7da0ebcdd166743d15c5adaa4f144c">cyhal_nvm_init</a>(&amp;nvm_obj);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Get NVM characteristics like NVM type, number of NVM regions and their organization</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__nvm.html#ga3aa3549df6e2053a945e8bcd0881c284">cyhal_nvm_get_info</a>(&amp;nvm_obj, &amp;nvm_info);</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> index = 0; index &lt; nvm_info.<a class="code hl_variable" href="group__group__hal__nvm.html#adb0900efa6ade915542adc7d9a707dc3">region_count</a>; index++)</div>
<div class="line">    {</div>
<div class="line">        <span class="keyword">const</span> <a class="code hl_struct" href="group__group__hal__nvm.html#structcyhal__nvm__region__info__t">cyhal_nvm_region_info_t</a>* region_info = nvm_info.<a class="code hl_variable" href="group__group__hal__nvm.html#a841ffcc9aa0fdbb9905377de86812fcd">regions</a>;</div>
<div class="line">        region_info         += index;</div>
<div class="line">        nvm_type            = region_info-&gt;<a class="code hl_variable" href="group__group__hal__nvm.html#aeb8dd9119e5394a12fa6ad7207abf1df">nvm_type</a>;</div>
<div class="line">        nvm_start_address   = region_info-&gt;<a class="code hl_variable" href="group__group__hal__nvm.html#a230b508b42ffec5a0df8c913932da876">start_address</a>;</div>
<div class="line">        nvm_size            = region_info-&gt;<a class="code hl_variable" href="group__group__hal__nvm.html#acd2fcf040444583971e53a06cb4ec385">size</a>;</div>
<div class="line">        nvm_sector_size     = region_info-&gt;<a class="code hl_variable" href="group__group__hal__nvm.html#a88c9a6de5db28e9e1ba59e5088d35827">sector_size</a>;</div>
<div class="line">        nvm_block_size      = region_info-&gt;<a class="code hl_variable" href="group__group__hal__nvm.html#a51e6070f5ff7eb9e12ea2f7b8f6332ae">block_size</a>;</div>
<div class="line">        is_erase_required   = region_info-&gt;<a class="code hl_variable" href="group__group__hal__nvm.html#a0ef9b9310b255270a6400bc2396e0bec">is_erase_required</a>;</div>
<div class="line">        nvm_erase_value     = region_info-&gt;<a class="code hl_variable" href="group__group__hal__nvm.html#a0962dee0293304664bb462b49e826f48">erase_value</a>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__hal__impl__hw__types_html_structcyhal__nvm__t"><div class="ttname"><a href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a></div><div class="ttdoc">NVM object.</div><div class="ttdef"><b>Definition:</b> cyhal_hw_types.h:721</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_a0962dee0293304664bb462b49e826f48"><div class="ttname"><a href="group__group__hal__nvm.html#a0962dee0293304664bb462b49e826f48">cyhal_nvm_region_info_t::erase_value</a></div><div class="ttdeci">uint8_t erase_value</div><div class="ttdoc">NVM erase value (if applicable).</div><div class="ttdef"><b>Definition:</b> cyhal_nvm.h:136</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_a0ef9b9310b255270a6400bc2396e0bec"><div class="ttname"><a href="group__group__hal__nvm.html#a0ef9b9310b255270a6400bc2396e0bec">cyhal_nvm_region_info_t::is_erase_required</a></div><div class="ttdeci">bool is_erase_required</div><div class="ttdoc">true = erase required before program, false = erase not required before program.</div><div class="ttdef"><b>Definition:</b> cyhal_nvm.h:135</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_a230b508b42ffec5a0df8c913932da876"><div class="ttname"><a href="group__group__hal__nvm.html#a230b508b42ffec5a0df8c913932da876">cyhal_nvm_region_info_t::start_address</a></div><div class="ttdeci">uint32_t start_address</div><div class="ttdoc">Base address of the distinct NVM region.</div><div class="ttdef"><b>Definition:</b> cyhal_nvm.h:130</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_a51e6070f5ff7eb9e12ea2f7b8f6332ae"><div class="ttname"><a href="group__group__hal__nvm.html#a51e6070f5ff7eb9e12ea2f7b8f6332ae">cyhal_nvm_region_info_t::block_size</a></div><div class="ttdeci">uint32_t block_size</div><div class="ttdoc">Block size (programming granularity) of the distinct NVM region.</div><div class="ttdef"><b>Definition:</b> cyhal_nvm.h:134</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_a841ffcc9aa0fdbb9905377de86812fcd"><div class="ttname"><a href="group__group__hal__nvm.html#a841ffcc9aa0fdbb9905377de86812fcd">cyhal_nvm_info_t::regions</a></div><div class="ttdeci">const cyhal_nvm_region_info_t * regions</div><div class="ttdoc">Array of the distinct NVM regions.</div><div class="ttdef"><b>Definition:</b> cyhal_nvm.h:143</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_a88c9a6de5db28e9e1ba59e5088d35827"><div class="ttname"><a href="group__group__hal__nvm.html#a88c9a6de5db28e9e1ba59e5088d35827">cyhal_nvm_region_info_t::sector_size</a></div><div class="ttdeci">uint32_t sector_size</div><div class="ttdoc">Sector size of the distinct NVM region.</div><div class="ttdef"><b>Definition:</b> cyhal_nvm.h:133</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_acd2fcf040444583971e53a06cb4ec385"><div class="ttname"><a href="group__group__hal__nvm.html#acd2fcf040444583971e53a06cb4ec385">cyhal_nvm_region_info_t::size</a></div><div class="ttdeci">uint32_t size</div><div class="ttdoc">Size of the distinct NVM region.</div><div class="ttdef"><b>Definition:</b> cyhal_nvm.h:132</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_adb0900efa6ade915542adc7d9a707dc3"><div class="ttname"><a href="group__group__hal__nvm.html#adb0900efa6ade915542adc7d9a707dc3">cyhal_nvm_info_t::region_count</a></div><div class="ttdeci">uint8_t region_count</div><div class="ttdoc">The number of distinct NVM regions.</div><div class="ttdef"><b>Definition:</b> cyhal_nvm.h:142</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_aeb8dd9119e5394a12fa6ad7207abf1df"><div class="ttname"><a href="group__group__hal__nvm.html#aeb8dd9119e5394a12fa6ad7207abf1df">cyhal_nvm_region_info_t::nvm_type</a></div><div class="ttdeci">cyhal_nvm_type_t nvm_type</div><div class="ttdoc">NVM type.</div><div class="ttdef"><b>Definition:</b> cyhal_nvm.h:129</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_ga3aa3549df6e2053a945e8bcd0881c284"><div class="ttname"><a href="group__group__hal__nvm.html#ga3aa3549df6e2053a945e8bcd0881c284">cyhal_nvm_get_info</a></div><div class="ttdeci">void cyhal_nvm_get_info(cyhal_nvm_t *obj, cyhal_nvm_info_t *info)</div><div class="ttdoc">Get details about the NVM memory regions such as NVM type, start address, size, is_erase_required,...</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_ga9f4757bde03ab2a481207b83b39f4e1e"><div class="ttname"><a href="group__group__hal__nvm.html#ga9f4757bde03ab2a481207b83b39f4e1e">cyhal_nvm_type_t</a></div><div class="ttdeci">cyhal_nvm_type_t</div><div class="ttdoc">Enum of Non-volatile memory (NVM) types.</div><div class="ttdef"><b>Definition:</b> cyhal_nvm.h:119</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_gace7da0ebcdd166743d15c5adaa4f144c"><div class="ttname"><a href="group__group__hal__nvm.html#gace7da0ebcdd166743d15c5adaa4f144c">cyhal_nvm_init</a></div><div class="ttdeci">cy_rslt_t cyhal_nvm_init(cyhal_nvm_t *obj)</div><div class="ttdoc">Initialize the cyhal_nvm_t object for accessing NVM through the HAL.</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_gga9f4757bde03ab2a481207b83b39f4e1ea2842bbba59be0d2ce09b8d35c048afc5"><div class="ttname"><a href="group__group__hal__nvm.html#gga9f4757bde03ab2a481207b83b39f4e1ea2842bbba59be0d2ce09b8d35c048afc5">CYHAL_NVM_TYPE_FLASH</a></div><div class="ttdeci">@ CYHAL_NVM_TYPE_FLASH</div><div class="ttdoc">Internal Flash.</div><div class="ttdef"><b>Definition:</b> cyhal_nvm.h:121</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_structcyhal__nvm__info__t"><div class="ttname"><a href="group__group__hal__nvm.html#structcyhal__nvm__info__t">cyhal_nvm_info_t</a></div><div class="ttdoc">Information about all of the regions of NVM memory.</div><div class="ttdef"><b>Definition:</b> cyhal_nvm.h:141</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_structcyhal__nvm__region__info__t"><div class="ttname"><a href="group__group__hal__nvm.html#structcyhal__nvm__region__info__t">cyhal_nvm_region_info_t</a></div><div class="ttdoc">Information about a single region of NVM memory.</div><div class="ttdef"><b>Definition:</b> cyhal_nvm.h:128</div></div>
</div><!-- fragment --><h2><a class="anchor" id="subsection_nvm_use_case_2"></a>
Snippet 2: Blocking NVM Erase-Write and Read</h2>
<p >Following code snippet demonstrates blocking NVM write. It uses a constant array with a size equaling the size of one NVM row/block. It uses blocking NVM write operation which blocks the caller until the write is completed. It then verifies the NVM data by comparing the NVM data with the written data. </p><div class="fragment"><div class="line"> </div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a>               nvm_obj;</div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__nvm.html#structcyhal__nvm__info__t">cyhal_nvm_info_t</a>          nvm_info;</div>
<div class="line">    <a class="code hl_typedef" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>          result = <a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a>; <span class="comment">// NVM Write Status</span></div>
<div class="line">    uint8_t            ram_data[512];            <span class="comment">// RAM data to be written to NVM</span></div>
<div class="line">    uint8_t            nvm_read_data[512];       <span class="comment">// RAM data read from NVM for validation</span></div>
<div class="line">    <span class="keywordtype">bool</span>               compare_status = <span class="keyword">false</span>;   <span class="comment">// Compare Status</span></div>
<div class="line">    uint32_t           nvm_addr;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Initialize NVM object</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__nvm.html#gace7da0ebcdd166743d15c5adaa4f144c">cyhal_nvm_init</a>(&amp;nvm_obj);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Get NVM characteristics like number of NVM regions, type, and their organization</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__nvm.html#ga3aa3549df6e2053a945e8bcd0881c284">cyhal_nvm_get_info</a>(&amp;nvm_obj, &amp;nvm_info);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// NVM region 0 last block</span></div>
<div class="line">    uint32_t block_num = (nvm_info.<a class="code hl_variable" href="group__group__hal__nvm.html#a841ffcc9aa0fdbb9905377de86812fcd">regions</a>[0].<a class="code hl_variable" href="group__group__hal__nvm.html#acd2fcf040444583971e53a06cb4ec385">size</a>/nvm_info.<a class="code hl_variable" href="group__group__hal__nvm.html#a841ffcc9aa0fdbb9905377de86812fcd">regions</a>[0].<a class="code hl_variable" href="group__group__hal__nvm.html#a51e6070f5ff7eb9e12ea2f7b8f6332ae">block_size</a>) - 1;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// NVM region 0 last block address</span></div>
<div class="line">    nvm_addr = nvm_info.<a class="code hl_variable" href="group__group__hal__nvm.html#a841ffcc9aa0fdbb9905377de86812fcd">regions</a>[0].<a class="code hl_variable" href="group__group__hal__nvm.html#a230b508b42ffec5a0df8c913932da876">start_address</a> + (block_num * nvm_info.<a class="code hl_variable" href="group__group__hal__nvm.html#a841ffcc9aa0fdbb9905377de86812fcd">regions</a>[0].<a class="code hl_variable" href="group__group__hal__nvm.html#a51e6070f5ff7eb9e12ea2f7b8f6332ae">block_size</a>);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Initialize the data in RAM that will be written into NVM</span></div>
<div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> index = 0; index &lt; <span class="keyword">sizeof</span>(ram_data); index++)</div>
<div class="line">    {</div>
<div class="line">        ram_data[index] = (uint8_t)index;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">if</span> (nvm_info.<a class="code hl_variable" href="group__group__hal__nvm.html#a841ffcc9aa0fdbb9905377de86812fcd">regions</a>[0].<a class="code hl_variable" href="group__group__hal__nvm.html#a0ef9b9310b255270a6400bc2396e0bec">is_erase_required</a>) <span class="comment">// Check if erase is required on the given NVM type</span></div>
<div class="line">    {</div>
<div class="line">        <span class="comment">// Blocking NVM erase prior to NVM write</span></div>
<div class="line">        result = <a class="code hl_function" href="group__group__hal__nvm.html#ga95c3271b674e93320dda17dabcb8c795">cyhal_nvm_erase</a>(&amp;nvm_obj, nvm_addr);</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">if</span> (result == <a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a>)</div>
<div class="line">    {</div>
<div class="line">        <span class="comment">// Blocking NVM write</span></div>
<div class="line">        result = <a class="code hl_function" href="group__group__hal__nvm.html#gaabe8235bedcfe8bf3cb14b873f9f9071">cyhal_nvm_program</a>(&amp;nvm_obj, nvm_addr, (<span class="keyword">const</span> uint32_t*)ram_data);</div>
<div class="line"> </div>
<div class="line">        <span class="keywordflow">if</span> (result == <a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a>)</div>
<div class="line">        {</div>
<div class="line">            <span class="comment">// Read NVM data</span></div>
<div class="line">            result =</div>
<div class="line">                <a class="code hl_function" href="group__group__hal__nvm.html#gaf347453abd0fe8571c36d9f400871498">cyhal_nvm_read</a>(&amp;nvm_obj, (uint32_t)nvm_addr, nvm_read_data, <span class="keyword">sizeof</span>(nvm_read_data));</div>
<div class="line">            <span class="keywordflow">if</span> (result == <a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a>)</div>
<div class="line">            {</div>
<div class="line">                <span class="comment">// Verify the data written into NVM by comparing it with the RAM data</span></div>
<div class="line">                <span class="keywordflow">if</span> (0 == memcmp(ram_data, nvm_read_data, <span class="keyword">sizeof</span>(nvm_read_data)))</div>
<div class="line">                {</div>
<div class="line">                    compare_status = <span class="keyword">true</span>;</div>
<div class="line">                }</div>
<div class="line">            }</div>
<div class="line">        }</div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">else</span></div>
<div class="line">    {</div>
<div class="line">        <span class="comment">// Error erasing NVM</span></div>
<div class="line">    }</div>
<div class="ttc" id="agroup__group__hal__nvm_html_ga95c3271b674e93320dda17dabcb8c795"><div class="ttname"><a href="group__group__hal__nvm.html#ga95c3271b674e93320dda17dabcb8c795">cyhal_nvm_erase</a></div><div class="ttdeci">cy_rslt_t cyhal_nvm_erase(cyhal_nvm_t *obj, uint32_t address)</div><div class="ttdoc">Erase one block of NVM starting at the given address.</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_gaabe8235bedcfe8bf3cb14b873f9f9071"><div class="ttname"><a href="group__group__hal__nvm.html#gaabe8235bedcfe8bf3cb14b873f9f9071">cyhal_nvm_program</a></div><div class="ttdeci">cy_rslt_t cyhal_nvm_program(cyhal_nvm_t *obj, uint32_t address, const uint32_t *data)</div><div class="ttdoc">Program one block with the provided data starting at the given address.</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_gaf347453abd0fe8571c36d9f400871498"><div class="ttname"><a href="group__group__hal__nvm.html#gaf347453abd0fe8571c36d9f400871498">cyhal_nvm_read</a></div><div class="ttdeci">cy_rslt_t cyhal_nvm_read(cyhal_nvm_t *obj, uint32_t address, uint8_t *data, size_t size)</div><div class="ttdoc">Read size amount of data starting from the given address of NVM.</div></div>
<div class="ttc" id="agroup__group__result_html_gaca79700fcc701534ce61778a9bcf57d1"><div class="ttname"><a href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a></div><div class="ttdeci">uint32_t cy_rslt_t</div><div class="ttdoc">Provides the result of an operation as a structured bitfield.</div><div class="ttdef"><b>Definition:</b> cy_result.h:438</div></div>
<div class="ttc" id="agroup__group__result_html_gaf58fac450d9fff4472f03ad68f6e546e"><div class="ttname"><a href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a></div><div class="ttdeci">#define CY_RSLT_SUCCESS</div><div class="ttdoc">cy_rslt_t return value indicating success</div><div class="ttdef"><b>Definition:</b> cy_result.h:465</div></div>
</div><!-- fragment --><h2><a class="anchor" id="subsection_nvm_use_case_3"></a>
Snippet 3: Non-blocking NVM Erase-Write and Read</h2>
<p >Following code snippet implements the non-blocking NVM write using polling to complete the NVM write operation. It uses a constant array with a size equaling the size of one NVM row/block. It uses a polling method to complete the NVM write operation. It then verifies the NVM data by comparing the NVM data with the written data. </p><div class="fragment"><div class="line"> </div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a>               nvm_obj;</div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__nvm.html#structcyhal__nvm__info__t">cyhal_nvm_info_t</a>          nvm_info;</div>
<div class="line">    <a class="code hl_typedef" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>          result = <a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a>; <span class="comment">// NVM Write Status</span></div>
<div class="line">    uint8_t            ram_data[512];            <span class="comment">// RAM data to be written to NVM</span></div>
<div class="line">    uint8_t            nvm_read_data[512];       <span class="comment">// RAM data read from NVM for validation</span></div>
<div class="line">    <span class="keywordtype">bool</span>               compare_status = <span class="keyword">false</span>;   <span class="comment">// Compare Status</span></div>
<div class="line">    uint32_t           nvm_addr;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Wait for 100ms for the NVM write to complete</span></div>
<div class="line">    uint32_t timeout = 100;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Initialize NVM object</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__nvm.html#gace7da0ebcdd166743d15c5adaa4f144c">cyhal_nvm_init</a>(&amp;nvm_obj);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Get NVM characteristics like number of NVM regions, type, and their organization</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__nvm.html#ga3aa3549df6e2053a945e8bcd0881c284">cyhal_nvm_get_info</a>(&amp;nvm_obj, &amp;nvm_info);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// NVM region 0 last block</span></div>
<div class="line">    uint32_t block_num = (nvm_info.<a class="code hl_variable" href="group__group__hal__nvm.html#a841ffcc9aa0fdbb9905377de86812fcd">regions</a>[0].<a class="code hl_variable" href="group__group__hal__nvm.html#acd2fcf040444583971e53a06cb4ec385">size</a>/nvm_info.<a class="code hl_variable" href="group__group__hal__nvm.html#a841ffcc9aa0fdbb9905377de86812fcd">regions</a>[0].<a class="code hl_variable" href="group__group__hal__nvm.html#a51e6070f5ff7eb9e12ea2f7b8f6332ae">block_size</a>) - 1;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// NVM region 0 last block address</span></div>
<div class="line">    nvm_addr = nvm_info.<a class="code hl_variable" href="group__group__hal__nvm.html#a841ffcc9aa0fdbb9905377de86812fcd">regions</a>[0].<a class="code hl_variable" href="group__group__hal__nvm.html#a230b508b42ffec5a0df8c913932da876">start_address</a> + (block_num * nvm_info.<a class="code hl_variable" href="group__group__hal__nvm.html#a841ffcc9aa0fdbb9905377de86812fcd">regions</a>[0].<a class="code hl_variable" href="group__group__hal__nvm.html#a51e6070f5ff7eb9e12ea2f7b8f6332ae">block_size</a>);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Initialize the data in RAM that will be written into NVM</span></div>
<div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> index = 0; index &lt; <span class="keyword">sizeof</span>(ram_data); index++)</div>
<div class="line">    {</div>
<div class="line">        ram_data[index] = (uint8_t)index;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">if</span> (nvm_info.<a class="code hl_variable" href="group__group__hal__nvm.html#a841ffcc9aa0fdbb9905377de86812fcd">regions</a>[0].<a class="code hl_variable" href="group__group__hal__nvm.html#a0ef9b9310b255270a6400bc2396e0bec">is_erase_required</a>) <span class="comment">// Check if erase is required on the given NVM type</span></div>
<div class="line">    {</div>
<div class="line">        <span class="comment">// Non-blocking NVM erase prior to NVM write</span></div>
<div class="line">        result = <a class="code hl_function" href="group__group__hal__nvm.html#ga56a8523c613f21677db309ce17a766d8">cyhal_nvm_start_erase</a>(&amp;nvm_obj, nvm_addr);</div>
<div class="line"> </div>
<div class="line">        <span class="keywordflow">if</span> (result == <a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a>)</div>
<div class="line">        {</div>
<div class="line">            <span class="keywordflow">while</span> (<span class="keyword">true</span> != <a class="code hl_function" href="group__group__hal__nvm.html#gafcd688373efbb96c516d09884f4a39c5">cyhal_nvm_is_operation_complete</a>(&amp;nvm_obj))</div>
<div class="line">            {</div>
<div class="line">                <span class="comment">// Wait for the NVM erase to be successful</span></div>
<div class="line">            }</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">else</span></div>
<div class="line">        {</div>
<div class="line">            <span class="comment">// Error erasing NVM</span></div>
<div class="line">        }</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">if</span> (result == <a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a>)</div>
<div class="line">    {</div>
<div class="line">        <span class="comment">// Non-blocking NVM write</span></div>
<div class="line">        result = <a class="code hl_function" href="group__group__hal__nvm.html#ga8e1a944669d347306e3bcead0d22c1e8">cyhal_nvm_start_program</a>(&amp;nvm_obj, nvm_addr, (<span class="keyword">const</span> uint32_t*)ram_data);</div>
<div class="line"> </div>
<div class="line">        <span class="keywordflow">if</span> (result == <a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a>)</div>
<div class="line">        {</div>
<div class="line">            <span class="comment">// Wait for the successful NVM write</span></div>
<div class="line">            <span class="keywordflow">while</span> ((<span class="keyword">true</span> != <a class="code hl_function" href="group__group__hal__nvm.html#gafcd688373efbb96c516d09884f4a39c5">cyhal_nvm_is_operation_complete</a>(&amp;nvm_obj)) &amp;&amp; (0 &lt; timeout))</div>
<div class="line">            {</div>
<div class="line">                timeout--;</div>
<div class="line">                <a class="code hl_function" href="group__group__hal__system.html#ga5f450769c1207d98134a9ced39adfdda">cyhal_system_delay_ms</a>(1); <span class="comment">// delay one millisecond each iteration</span></div>
<div class="line">            }</div>
<div class="line"> </div>
<div class="line">            <span class="comment">// Flag error if the expected NVM write status not returned within timeout period</span></div>
<div class="line">            <span class="keywordflow">if</span> (0 != timeout)</div>
<div class="line">            {</div>
<div class="line">                <span class="comment">// Read NVM data</span></div>
<div class="line">                result = <a class="code hl_function" href="group__group__hal__nvm.html#gaf347453abd0fe8571c36d9f400871498">cyhal_nvm_read</a>(&amp;nvm_obj, nvm_addr, nvm_read_data, <span class="keyword">sizeof</span>(nvm_read_data));</div>
<div class="line">                <span class="keywordflow">if</span> (result == <a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a>)</div>
<div class="line">                {</div>
<div class="line">                    <span class="comment">// Verify the data written into NVM by comparing it with the RAM data</span></div>
<div class="line">                    <span class="keywordflow">if</span> (0 == memcmp(ram_data, nvm_read_data, <span class="keyword">sizeof</span>(nvm_read_data)))</div>
<div class="line">                    {</div>
<div class="line">                        compare_status = <span class="keyword">true</span>;</div>
<div class="line">                    }</div>
<div class="line">                }</div>
<div class="line">            }</div>
<div class="line">        }</div>
<div class="line">    }</div>
<div class="ttc" id="agroup__group__hal__nvm_html_ga56a8523c613f21677db309ce17a766d8"><div class="ttname"><a href="group__group__hal__nvm.html#ga56a8523c613f21677db309ce17a766d8">cyhal_nvm_start_erase</a></div><div class="ttdeci">cy_rslt_t cyhal_nvm_start_erase(cyhal_nvm_t *obj, uint32_t address)</div><div class="ttdoc">Start an asynchronous erase of a single block of NVM starting at the given address.</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_ga8e1a944669d347306e3bcead0d22c1e8"><div class="ttname"><a href="group__group__hal__nvm.html#ga8e1a944669d347306e3bcead0d22c1e8">cyhal_nvm_start_program</a></div><div class="ttdeci">cy_rslt_t cyhal_nvm_start_program(cyhal_nvm_t *obj, uint32_t address, const uint32_t *data)</div><div class="ttdoc">Start asynchronous programming of a single block of NVM starting at the given address.</div></div>
<div class="ttc" id="agroup__group__hal__nvm_html_gafcd688373efbb96c516d09884f4a39c5"><div class="ttname"><a href="group__group__hal__nvm.html#gafcd688373efbb96c516d09884f4a39c5">cyhal_nvm_is_operation_complete</a></div><div class="ttdeci">bool cyhal_nvm_is_operation_complete(cyhal_nvm_t *obj)</div><div class="ttdoc">Reports status of the last NVM operation.</div></div>
<div class="ttc" id="agroup__group__hal__system_html_ga5f450769c1207d98134a9ced39adfdda"><div class="ttname"><a href="group__group__hal__system.html#ga5f450769c1207d98134a9ced39adfdda">cyhal_system_delay_ms</a></div><div class="ttdeci">cy_rslt_t cyhal_system_delay_ms(uint32_t milliseconds)</div><div class="ttdoc">Requests that the current operation delays for at least the specified length of time.</div></div>
</div><!-- fragment --> <table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="groups" name="groups"></a>
API Reference</h2></td></tr>
<tr class="memitem:group__group__hal__results__nvm"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__results__nvm.html">NVM HAL Results</a></td></tr>
<tr class="memdesc:group__group__hal__results__nvm"><td class="mdescLeft">&#160;</td><td class="mdescRight">NVM specific return codes. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:structcyhal__nvm__region__info__t"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__nvm.html#structcyhal__nvm__region__info__t">cyhal_nvm_region_info_t</a></td></tr>
<tr class="memdesc:structcyhal__nvm__region__info__t"><td class="mdescLeft">&#160;</td><td class="mdescRight">Information about a single region of NVM memory.  <a href="group__group__hal__nvm.html#structcyhal__nvm__region__info__t">More...</a><br /></td></tr>
<tr class="separator:structcyhal__nvm__region__info__t"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:structcyhal__nvm__info__t"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__nvm.html#structcyhal__nvm__info__t">cyhal_nvm_info_t</a></td></tr>
<tr class="memdesc:structcyhal__nvm__info__t"><td class="mdescLeft">&#160;</td><td class="mdescRight">Information about all of the regions of NVM memory.  <a href="group__group__hal__nvm.html#structcyhal__nvm__info__t">More...</a><br /></td></tr>
<tr class="separator:structcyhal__nvm__info__t"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="enum-members" name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:ga9f4757bde03ab2a481207b83b39f4e1e"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__nvm.html#ga9f4757bde03ab2a481207b83b39f4e1e">cyhal_nvm_type_t</a> { <br />
&#160;&#160;<a class="el" href="group__group__hal__nvm.html#gga9f4757bde03ab2a481207b83b39f4e1ea85d9b07ee848e8e7c1ad1c89ad0e3b1f">CYHAL_NVM_TYPE_INVALID</a> = 0U
, <br />
&#160;&#160;<a class="el" href="group__group__hal__nvm.html#gga9f4757bde03ab2a481207b83b39f4e1ea2842bbba59be0d2ce09b8d35c048afc5">CYHAL_NVM_TYPE_FLASH</a> = 1U
, <br />
&#160;&#160;<a class="el" href="group__group__hal__nvm.html#gga9f4757bde03ab2a481207b83b39f4e1ea67057d1e259a906a6391610f0239e90c">CYHAL_NVM_TYPE_RRAM</a> = 2U
, <br />
&#160;&#160;<a class="el" href="group__group__hal__nvm.html#gga9f4757bde03ab2a481207b83b39f4e1eaa4505c0d72a30907ca8e8b4056c5b854">CYHAL_NVM_TYPE_OTP</a> = 3U
<br />
 }</td></tr>
<tr class="memdesc:ga9f4757bde03ab2a481207b83b39f4e1e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enum of Non-volatile memory (NVM) types.  <a href="group__group__hal__nvm.html#ga9f4757bde03ab2a481207b83b39f4e1e">More...</a><br /></td></tr>
<tr class="separator:ga9f4757bde03ab2a481207b83b39f4e1e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gace7da0ebcdd166743d15c5adaa4f144c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__nvm.html#gace7da0ebcdd166743d15c5adaa4f144c">cyhal_nvm_init</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *obj)</td></tr>
<tr class="memdesc:gace7da0ebcdd166743d15c5adaa4f144c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> object for accessing NVM through the HAL.  <a href="group__group__hal__nvm.html#gace7da0ebcdd166743d15c5adaa4f144c">More...</a><br /></td></tr>
<tr class="separator:gace7da0ebcdd166743d15c5adaa4f144c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad16f3066d4356c5da226f348767915ea"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__nvm.html#gad16f3066d4356c5da226f348767915ea">cyhal_nvm_free</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *obj)</td></tr>
<tr class="memdesc:gad16f3066d4356c5da226f348767915ea"><td class="mdescLeft">&#160;</td><td class="mdescRight">Free resources associated with the NVM HAL driver.  <a href="group__group__hal__nvm.html#gad16f3066d4356c5da226f348767915ea">More...</a><br /></td></tr>
<tr class="separator:gad16f3066d4356c5da226f348767915ea"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3aa3549df6e2053a945e8bcd0881c284"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__nvm.html#ga3aa3549df6e2053a945e8bcd0881c284">cyhal_nvm_get_info</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *obj, <a class="el" href="group__group__hal__nvm.html#structcyhal__nvm__info__t">cyhal_nvm_info_t</a> *info)</td></tr>
<tr class="memdesc:ga3aa3549df6e2053a945e8bcd0881c284"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get details about the NVM memory regions such as NVM type, start address, size, is_erase_required, and erase values etc.  <a href="group__group__hal__nvm.html#ga3aa3549df6e2053a945e8bcd0881c284">More...</a><br /></td></tr>
<tr class="separator:ga3aa3549df6e2053a945e8bcd0881c284"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf347453abd0fe8571c36d9f400871498"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__nvm.html#gaf347453abd0fe8571c36d9f400871498">cyhal_nvm_read</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *obj, uint32_t address, uint8_t *data, size_t size)</td></tr>
<tr class="memdesc:gaf347453abd0fe8571c36d9f400871498"><td class="mdescLeft">&#160;</td><td class="mdescRight">Read size amount of data starting from the given address of NVM.  <a href="group__group__hal__nvm.html#gaf347453abd0fe8571c36d9f400871498">More...</a><br /></td></tr>
<tr class="separator:gaf347453abd0fe8571c36d9f400871498"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga95c3271b674e93320dda17dabcb8c795"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__nvm.html#ga95c3271b674e93320dda17dabcb8c795">cyhal_nvm_erase</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *obj, uint32_t address)</td></tr>
<tr class="memdesc:ga95c3271b674e93320dda17dabcb8c795"><td class="mdescLeft">&#160;</td><td class="mdescRight">Erase one block of NVM starting at the given address.  <a href="group__group__hal__nvm.html#ga95c3271b674e93320dda17dabcb8c795">More...</a><br /></td></tr>
<tr class="separator:ga95c3271b674e93320dda17dabcb8c795"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafc26bb4e9e30c05618bc155a513004bc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__nvm.html#gafc26bb4e9e30c05618bc155a513004bc">cyhal_nvm_write</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *obj, uint32_t address, const uint32_t *data)</td></tr>
<tr class="memdesc:gafc26bb4e9e30c05618bc155a513004bc"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function erases the block, if required, and writes the new data into the block starting at the given address.  <a href="group__group__hal__nvm.html#gafc26bb4e9e30c05618bc155a513004bc">More...</a><br /></td></tr>
<tr class="separator:gafc26bb4e9e30c05618bc155a513004bc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacf60b2bcce6d2bce8ca44f7a1ef5d6e1"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__nvm.html#gacf60b2bcce6d2bce8ca44f7a1ef5d6e1">cyhal_nvm_otp_write</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *obj, uint32_t address, uint8_t data)</td></tr>
<tr class="memdesc:gacf60b2bcce6d2bce8ca44f7a1ef5d6e1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Write one-time data to the given byte location in the provided block of NVM OTP region.  <a href="group__group__hal__nvm.html#gacf60b2bcce6d2bce8ca44f7a1ef5d6e1">More...</a><br /></td></tr>
<tr class="separator:gacf60b2bcce6d2bce8ca44f7a1ef5d6e1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaabe8235bedcfe8bf3cb14b873f9f9071"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__nvm.html#gaabe8235bedcfe8bf3cb14b873f9f9071">cyhal_nvm_program</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *obj, uint32_t address, const uint32_t *data)</td></tr>
<tr class="memdesc:gaabe8235bedcfe8bf3cb14b873f9f9071"><td class="mdescLeft">&#160;</td><td class="mdescRight">Program one block with the provided data starting at the given address.  <a href="group__group__hal__nvm.html#gaabe8235bedcfe8bf3cb14b873f9f9071">More...</a><br /></td></tr>
<tr class="separator:gaabe8235bedcfe8bf3cb14b873f9f9071"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga56a8523c613f21677db309ce17a766d8"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__nvm.html#ga56a8523c613f21677db309ce17a766d8">cyhal_nvm_start_erase</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *obj, uint32_t address)</td></tr>
<tr class="memdesc:ga56a8523c613f21677db309ce17a766d8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Start an asynchronous erase of a single block of NVM starting at the given address.  <a href="group__group__hal__nvm.html#ga56a8523c613f21677db309ce17a766d8">More...</a><br /></td></tr>
<tr class="separator:ga56a8523c613f21677db309ce17a766d8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab964f15c367481078c16caf88a68287b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__nvm.html#gab964f15c367481078c16caf88a68287b">cyhal_nvm_start_write</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *obj, uint32_t address, const uint32_t *data)</td></tr>
<tr class="memdesc:gab964f15c367481078c16caf88a68287b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Start an asynchronous write (Erase if required + Program) on single block of NVM starting at the given address.  <a href="group__group__hal__nvm.html#gab964f15c367481078c16caf88a68287b">More...</a><br /></td></tr>
<tr class="separator:gab964f15c367481078c16caf88a68287b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8e1a944669d347306e3bcead0d22c1e8"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__nvm.html#ga8e1a944669d347306e3bcead0d22c1e8">cyhal_nvm_start_program</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *obj, uint32_t address, const uint32_t *data)</td></tr>
<tr class="memdesc:ga8e1a944669d347306e3bcead0d22c1e8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Start asynchronous programming of a single block of NVM starting at the given address.  <a href="group__group__hal__nvm.html#ga8e1a944669d347306e3bcead0d22c1e8">More...</a><br /></td></tr>
<tr class="separator:ga8e1a944669d347306e3bcead0d22c1e8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafcd688373efbb96c516d09884f4a39c5"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__nvm.html#gafcd688373efbb96c516d09884f4a39c5">cyhal_nvm_is_operation_complete</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *obj)</td></tr>
<tr class="memdesc:gafcd688373efbb96c516d09884f4a39c5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reports status of the last NVM operation.  <a href="group__group__hal__nvm.html#gafcd688373efbb96c516d09884f4a39c5">More...</a><br /></td></tr>
<tr class="separator:gafcd688373efbb96c516d09884f4a39c5"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<hr/><h2 class="groupheader">Data Structure Documentation</h2>
<a name="structcyhal__nvm__region__info__t" id="structcyhal__nvm__region__info__t"></a>
<h2 class="memtitle"><span class="permalink"><a href="#structcyhal__nvm__region__info__t">&#9670;&nbsp;</a></span>cyhal_nvm_region_info_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct cyhal_nvm_region_info_t</td>
        </tr>
      </table>
</div><div class="memdoc">
<table class="fieldtable">
<tr><th colspan="3">Data Fields</th></tr>
<tr><td class="fieldtype">
<a id="aeb8dd9119e5394a12fa6ad7207abf1df" name="aeb8dd9119e5394a12fa6ad7207abf1df"></a><a class="el" href="group__group__hal__nvm.html#ga9f4757bde03ab2a481207b83b39f4e1e">cyhal_nvm_type_t</a></td>
<td class="fieldname">
nvm_type</td>
<td class="fielddoc">
NVM type. </td></tr>
<tr><td class="fieldtype">
<a id="a230b508b42ffec5a0df8c913932da876" name="a230b508b42ffec5a0df8c913932da876"></a>uint32_t</td>
<td class="fieldname">
start_address</td>
<td class="fielddoc">
Base address of the distinct NVM region. </td></tr>
<tr><td class="fieldtype">
<a id="adff5dc5618a30b32ff1e16fe0da622ad" name="adff5dc5618a30b32ff1e16fe0da622ad"></a>uint32_t</td>
<td class="fieldname">
offset</td>
<td class="fielddoc">
Offset to the address in the distinct NVM region. </td></tr>
<tr><td class="fieldtype">
<a id="acd2fcf040444583971e53a06cb4ec385" name="acd2fcf040444583971e53a06cb4ec385"></a>uint32_t</td>
<td class="fieldname">
size</td>
<td class="fielddoc">
Size of the distinct NVM region. </td></tr>
<tr><td class="fieldtype">
<a id="a88c9a6de5db28e9e1ba59e5088d35827" name="a88c9a6de5db28e9e1ba59e5088d35827"></a>uint32_t</td>
<td class="fieldname">
sector_size</td>
<td class="fielddoc">
Sector size of the distinct NVM region. </td></tr>
<tr><td class="fieldtype">
<a id="a51e6070f5ff7eb9e12ea2f7b8f6332ae" name="a51e6070f5ff7eb9e12ea2f7b8f6332ae"></a>uint32_t</td>
<td class="fieldname">
block_size</td>
<td class="fielddoc">
Block size (programming granularity) of the distinct NVM region. </td></tr>
<tr><td class="fieldtype">
<a id="a0ef9b9310b255270a6400bc2396e0bec" name="a0ef9b9310b255270a6400bc2396e0bec"></a>bool</td>
<td class="fieldname">
is_erase_required</td>
<td class="fielddoc">
true = erase required before program, false = erase not required before program. </td></tr>
<tr><td class="fieldtype">
<a id="a0962dee0293304664bb462b49e826f48" name="a0962dee0293304664bb462b49e826f48"></a>uint8_t</td>
<td class="fieldname">
erase_value</td>
<td class="fielddoc">
NVM erase value (if applicable). </td></tr>
</table>

</div>
</div>
<a name="structcyhal__nvm__info__t" id="structcyhal__nvm__info__t"></a>
<h2 class="memtitle"><span class="permalink"><a href="#structcyhal__nvm__info__t">&#9670;&nbsp;</a></span>cyhal_nvm_info_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct cyhal_nvm_info_t</td>
        </tr>
      </table>
</div><div class="memdoc">
<table class="fieldtable">
<tr><th colspan="3">Data Fields</th></tr>
<tr><td class="fieldtype">
<a id="adb0900efa6ade915542adc7d9a707dc3" name="adb0900efa6ade915542adc7d9a707dc3"></a>uint8_t</td>
<td class="fieldname">
region_count</td>
<td class="fielddoc">
The number of distinct NVM regions. </td></tr>
<tr><td class="fieldtype">
<a id="a841ffcc9aa0fdbb9905377de86812fcd" name="a841ffcc9aa0fdbb9905377de86812fcd"></a>const <a class="el" href="group__group__hal__nvm.html#structcyhal__nvm__region__info__t">cyhal_nvm_region_info_t</a> *</td>
<td class="fieldname">
regions</td>
<td class="fielddoc">
Array of the distinct NVM regions. </td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a id="ga9f4757bde03ab2a481207b83b39f4e1e" name="ga9f4757bde03ab2a481207b83b39f4e1e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9f4757bde03ab2a481207b83b39f4e1e">&#9670;&nbsp;</a></span>cyhal_nvm_type_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__group__hal__nvm.html#ga9f4757bde03ab2a481207b83b39f4e1e">cyhal_nvm_type_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Enum of Non-volatile memory (NVM) types. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="gga9f4757bde03ab2a481207b83b39f4e1ea85d9b07ee848e8e7c1ad1c89ad0e3b1f" name="gga9f4757bde03ab2a481207b83b39f4e1ea85d9b07ee848e8e7c1ad1c89ad0e3b1f"></a>CYHAL_NVM_TYPE_INVALID&#160;</td><td class="fielddoc"><p >Invalid type of NVM. </p>
</td></tr>
<tr><td class="fieldname"><a id="gga9f4757bde03ab2a481207b83b39f4e1ea2842bbba59be0d2ce09b8d35c048afc5" name="gga9f4757bde03ab2a481207b83b39f4e1ea2842bbba59be0d2ce09b8d35c048afc5"></a>CYHAL_NVM_TYPE_FLASH&#160;</td><td class="fielddoc"><p >Internal Flash. </p>
</td></tr>
<tr><td class="fieldname"><a id="gga9f4757bde03ab2a481207b83b39f4e1ea67057d1e259a906a6391610f0239e90c" name="gga9f4757bde03ab2a481207b83b39f4e1ea67057d1e259a906a6391610f0239e90c"></a>CYHAL_NVM_TYPE_RRAM&#160;</td><td class="fielddoc"><p >RRAM. </p>
</td></tr>
<tr><td class="fieldname"><a id="gga9f4757bde03ab2a481207b83b39f4e1eaa4505c0d72a30907ca8e8b4056c5b854" name="gga9f4757bde03ab2a481207b83b39f4e1eaa4505c0d72a30907ca8e8b4056c5b854"></a>CYHAL_NVM_TYPE_OTP&#160;</td><td class="fielddoc"><p >OTP. </p>
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="gace7da0ebcdd166743d15c5adaa4f144c" name="gace7da0ebcdd166743d15c5adaa4f144c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gace7da0ebcdd166743d15c5adaa4f144c">&#9670;&nbsp;</a></span>cyhal_nvm_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_nvm_init </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialize the <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> object for accessing NVM through the HAL. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>Pointer to a NVM object. The caller must allocate the memory for this object but the init function will initialize its contents. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the init request. Returns <a class="el" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> on successful operation. </dd></dl>

</div>
</div>
<a id="gad16f3066d4356c5da226f348767915ea" name="gad16f3066d4356c5da226f348767915ea"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad16f3066d4356c5da226f348767915ea">&#9670;&nbsp;</a></span>cyhal_nvm_free()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cyhal_nvm_free </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Free resources associated with the NVM HAL driver. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">obj</td><td>The NVM object. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga3aa3549df6e2053a945e8bcd0881c284" name="ga3aa3549df6e2053a945e8bcd0881c284"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3aa3549df6e2053a945e8bcd0881c284">&#9670;&nbsp;</a></span>cyhal_nvm_get_info()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cyhal_nvm_get_info </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__nvm.html#structcyhal__nvm__info__t">cyhal_nvm_info_t</a> *&#160;</td>
          <td class="paramname"><em>info</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get details about the NVM memory regions such as NVM type, start address, size, is_erase_required, and erase values etc. </p>
<p >Refer <a class="el" href="group__group__hal__nvm.html#structcyhal__nvm__info__t">cyhal_nvm_info_t</a>, <a class="el" href="group__group__hal__nvm.html#structcyhal__nvm__region__info__t" title="Information about a single region of NVM memory.">cyhal_nvm_region_info_t</a> for more information.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The NVM object. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">info</td><td>The NVM characteristic info.</td></tr>
  </table>
  </dd>
</dl>
<p>Refer <a class="el" href="group__group__hal__nvm.html#subsection_nvm_use_case_1">Snippet 1: Get NVM Characteristics</a> for more information. </p>

</div>
</div>
<a id="gaf347453abd0fe8571c36d9f400871498" name="gaf347453abd0fe8571c36d9f400871498"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf347453abd0fe8571c36d9f400871498">&#9670;&nbsp;</a></span>cyhal_nvm_read()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_nvm_read </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>address</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Read size amount of data starting from the given address of NVM. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The NVM object. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">address</td><td>Address to begin reading from. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">data</td><td>The buffer to read data into. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">size</td><td>The number of bytes to read. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the read request. Returns <a class="el" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> on successful operation.</dd></dl>
<p>Refer <a class="el" href="group__group__hal__nvm.html#subsection_nvm_use_case_2">Snippet 2: Blocking NVM Erase-Write and Read</a> for more information. </p>

</div>
</div>
<a id="ga95c3271b674e93320dda17dabcb8c795" name="ga95c3271b674e93320dda17dabcb8c795"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga95c3271b674e93320dda17dabcb8c795">&#9670;&nbsp;</a></span>cyhal_nvm_erase()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_nvm_erase </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>address</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Erase one block of NVM starting at the given address. </p>
<p >The address must be at block boundary. This will block until the erase operation is complete.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__group__hal__nvm.html#ga3aa3549df6e2053a945e8bcd0881c284" title="Get details about the NVM memory regions such as NVM type, start address, size, is_erase_required,...">cyhal_nvm_get_info()</a> to get the NVM characteristics for legal address values, is erase required/applicable, and the erase block size(if applicable).</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The NVM object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">address</td><td>The block address to be erased </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the erase request. Returns <a class="el" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> on successful operation.</dd></dl>
<p>Refer <a class="el" href="group__group__hal__nvm.html#subsection_nvm_use_case_2">Snippet 2: Blocking NVM Erase-Write and Read</a> for more information. </p>

</div>
</div>
<a id="gafc26bb4e9e30c05618bc155a513004bc" name="gafc26bb4e9e30c05618bc155a513004bc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gafc26bb4e9e30c05618bc155a513004bc">&#9670;&nbsp;</a></span>cyhal_nvm_write()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_nvm_write </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>address</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint32_t *&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function erases the block, if required, and writes the new data into the block starting at the given address. </p>
<p >The address must be at block boundary. This will block until the write operation is complete.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__group__hal__nvm.html#ga3aa3549df6e2053a945e8bcd0881c284" title="Get details about the NVM memory regions such as NVM type, start address, size, is_erase_required,...">cyhal_nvm_get_info()</a> to get the NVM characteristics for legal address values and the write block size. The provided data buffer must be at least as large as the NVM block_size. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>Generally the <code>data</code> to be written must be located in the SRAM memory region.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The NVM object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">address</td><td>The address of the block to be written </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">data</td><td>The data buffer to be written to the NVM block </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the write request. Returns <a class="el" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> on successful operation.</dd></dl>
<p>Refer <a class="el" href="group__group__hal__nvm.html#subsection_nvm_use_case_2">Snippet 2: Blocking NVM Erase-Write and Read</a> for more information. </p>

</div>
</div>
<a id="gacf60b2bcce6d2bce8ca44f7a1ef5d6e1" name="gacf60b2bcce6d2bce8ca44f7a1ef5d6e1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gacf60b2bcce6d2bce8ca44f7a1ef5d6e1">&#9670;&nbsp;</a></span>cyhal_nvm_otp_write()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_nvm_otp_write </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>address</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Write one-time data to the given byte location in the provided block of NVM OTP region. </p>
<p >The block must be within the defined block range of the OTP (refer the device datasheet for more information).</p>
<dl class="section note"><dt>Note</dt><dd>You can only ONCE write data at desired byte in specific block, if you will try to do it more times, you can have broken data at this location. </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__group__hal__nvm.html#ga3aa3549df6e2053a945e8bcd0881c284" title="Get details about the NVM memory regions such as NVM type, start address, size, is_erase_required,...">cyhal_nvm_get_info()</a> to get the NVM OTP region characteristics for legal address values, size and the OTP block size.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The NVM object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">address</td><td>The address of the block to be written </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">data</td><td>The data to be written to the OTP memory </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the program request. Returns <a class="el" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> on successful operation. </dd></dl>

</div>
</div>
<a id="gaabe8235bedcfe8bf3cb14b873f9f9071" name="gaabe8235bedcfe8bf3cb14b873f9f9071"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaabe8235bedcfe8bf3cb14b873f9f9071">&#9670;&nbsp;</a></span>cyhal_nvm_program()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_nvm_program </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>address</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint32_t *&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Program one block with the provided data starting at the given address. </p>
<p >The address must be at block boundary. This will block until the write operation is complete.</p>
<dl class="section note"><dt>Note</dt><dd>This function does not erase the block prior to writing. The block must be erased first via a separate call to erase. </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__group__hal__nvm.html#ga3aa3549df6e2053a945e8bcd0881c284" title="Get details about the NVM memory regions such as NVM type, start address, size, is_erase_required,...">cyhal_nvm_get_info()</a> to get the NVM characteristics for legal address values and the total block size. The provided data buffer must be at least as large as the NVM block_size. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>Generally the <code>data</code> to be programmed must be located in the SRAM memory region.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The NVM object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">address</td><td>The address of the block to be programmed </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">data</td><td>The data buffer to be programmed to the NVM block </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the program request. Returns <a class="el" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> on successful operation. </dd></dl>

</div>
</div>
<a id="ga56a8523c613f21677db309ce17a766d8" name="ga56a8523c613f21677db309ce17a766d8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga56a8523c613f21677db309ce17a766d8">&#9670;&nbsp;</a></span>cyhal_nvm_start_erase()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_nvm_start_erase </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>address</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Start an asynchronous erase of a single block of NVM starting at the given address. </p>
<p >Returns immediately and reports a successful start or reason for failure. The address must be aligned on a block boundary.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__group__hal__nvm.html#ga3aa3549df6e2053a945e8bcd0881c284" title="Get details about the NVM memory regions such as NVM type, start address, size, is_erase_required,...">cyhal_nvm_get_info()</a> to get the NVM characteristics for legal address values, is erase required/applicable, and the erase block size(if applicable).</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The NVM object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">address</td><td>The block address to be erased </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the start_erase request.</dd></dl>
<p>Refer <a class="el" href="group__group__hal__nvm.html#subsection_nvm_use_case_3">Snippet 3: Non-blocking NVM Erase-Write and Read</a> for more information. </p>

</div>
</div>
<a id="gab964f15c367481078c16caf88a68287b" name="gab964f15c367481078c16caf88a68287b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab964f15c367481078c16caf88a68287b">&#9670;&nbsp;</a></span>cyhal_nvm_start_write()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_nvm_start_write </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>address</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint32_t *&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Start an asynchronous write (Erase if required + Program) on single block of NVM starting at the given address. </p>
<p >Returns immediately and reports a successful start or reason for failure. The address must be aligned on a block boundary.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__group__hal__nvm.html#ga3aa3549df6e2053a945e8bcd0881c284" title="Get details about the NVM memory regions such as NVM type, start address, size, is_erase_required,...">cyhal_nvm_get_info()</a> to get the NVM characteristics for legal address values and the write block size. The provided data buffer must be at least as large as the NVM block_size. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>Generally the <code>data</code> to be written must be located in the SRAM memory region.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The NVM object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">address</td><td>The address of the block to be written </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">data</td><td>The data buffer to be written to the NVM block </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the start_write request.</dd></dl>
<p>Refer <a class="el" href="group__group__hal__nvm.html#subsection_nvm_use_case_3">Snippet 3: Non-blocking NVM Erase-Write and Read</a> for more information. </p>

</div>
</div>
<a id="ga8e1a944669d347306e3bcead0d22c1e8" name="ga8e1a944669d347306e3bcead0d22c1e8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga8e1a944669d347306e3bcead0d22c1e8">&#9670;&nbsp;</a></span>cyhal_nvm_start_program()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_nvm_start_program </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>address</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint32_t *&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Start asynchronous programming of a single block of NVM starting at the given address. </p>
<p >Returns immediately and reports a successful start or reason for failure.</p>
<dl class="section note"><dt>Note</dt><dd>This function does not erase the block prior to writing. The block must be erased first via a separate call to erase.</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__group__hal__nvm.html#ga3aa3549df6e2053a945e8bcd0881c284" title="Get details about the NVM memory regions such as NVM type, start address, size, is_erase_required,...">cyhal_nvm_get_info()</a> to get the NVM characteristics for legal address values and the total block size. The provided data buffer must be at least as large as the NVM block_size. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>Generally the <code>data</code> to be programmed must be located in the SRAM memory region.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The NVM object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">address</td><td>The address of the block to be programmed </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">data</td><td>The data buffer to be programmed to the NVM block </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the program request. Returns <a class="el" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> on successful operation. </dd></dl>

</div>
</div>
<a id="gafcd688373efbb96c516d09884f4a39c5" name="gafcd688373efbb96c516d09884f4a39c5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gafcd688373efbb96c516d09884f4a39c5">&#9670;&nbsp;</a></span>cyhal_nvm_is_operation_complete()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool cyhal_nvm_is_operation_complete </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__nvm__t">cyhal_nvm_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reports status of the last NVM operation. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The NVM object </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if NVM operation is complete. false otherwise. </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>Hardware Abstraction Layer (HAL)</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
